home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / copsnrob.c < prev    next >
C/C++ Source or Header  |  2000-05-13  |  4KB  |  158 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11. #include "artwork.h"
  12.  
  13.  
  14. static const struct artwork_element copsnrob_overlay[] =
  15. {
  16.     {{  0,  71, 0, 255}, 0x40, 0x40, 0xc0, OVERLAY_DEFAULT_OPACITY},    /* blue */
  17.     {{ 72, 187, 0, 255}, 0xf0, 0xf0, 0x30, OVERLAY_DEFAULT_OPACITY},    /* yellow */
  18.     {{188, 255, 0, 255}, 0xbd, 0x9b, 0x13, OVERLAY_DEFAULT_OPACITY},    /* amber */
  19.     {{-1,-1,-1,-1},0,0,0,0}
  20. };
  21.  
  22. unsigned char *copsnrob_bulletsram;
  23. unsigned char *copsnrob_carimage;
  24. unsigned char *copsnrob_cary;
  25. unsigned char *copsnrob_trucky;
  26.  
  27.  
  28. int copsnrob_vh_start(void)
  29. {
  30.     overlay_create(copsnrob_overlay, 2, Machine->drv->total_colors - 2);
  31.  
  32.     return 0;
  33. }
  34.  
  35.  
  36. /***************************************************************************
  37.  
  38.   Draw the game screen in the given osd_bitmap.
  39.   Do NOT call osd_update_display() from this function, it will be called by
  40.   the main emulation engine.
  41.  
  42. ***************************************************************************/
  43. void copsnrob_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  44. {
  45.     int offs, x;
  46.  
  47.  
  48.     palette_recalc();
  49.  
  50.  
  51.     /* redrawing the entire display is faster in this case */
  52.  
  53.     for (offs = videoram_size;offs >= 0;offs--)
  54.     {
  55.         int sx,sy;
  56.  
  57.         sx = 31 - (offs % 32);
  58.         sy = offs / 32;
  59.  
  60.         drawgfx(bitmap,Machine->gfx[0],
  61.                 videoram[offs] & 0x3f,0,
  62.                 0,0,
  63.                 8*sx,8*sy,
  64.                 &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  65.     }
  66.  
  67.  
  68.     /* Draw the cars. Positioning was based on a screen shot */
  69.     if (copsnrob_cary[0])
  70.     {
  71.         drawgfx(bitmap,Machine->gfx[1],
  72.                 copsnrob_carimage[0],0,
  73.                 1,0,
  74.                 0xe4,256-copsnrob_cary[0],
  75.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  76.     }
  77.  
  78.     if (copsnrob_cary[1])
  79.     {
  80.         drawgfx(bitmap,Machine->gfx[1],
  81.                 copsnrob_carimage[1],0,
  82.                 1,0,
  83.                 0xc4,256-copsnrob_cary[1],
  84.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  85.     }
  86.  
  87.     if (copsnrob_cary[2])
  88.     {
  89.         drawgfx(bitmap,Machine->gfx[1],
  90.                 copsnrob_carimage[2],0,
  91.                 0,0,
  92.                 0x24,256-copsnrob_cary[2],
  93.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  94.     }
  95.  
  96.     if (copsnrob_cary[3])
  97.     {
  98.         drawgfx(bitmap,Machine->gfx[1],
  99.                 copsnrob_carimage[3],0,
  100.                 0,0,
  101.                 0x04,256-copsnrob_cary[3],
  102.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  103.     }
  104.  
  105.  
  106.     /* Draw the beer truck. Positioning was based on a screen shot.
  107.        Even though the manual says there can be up to 3 beer trucks
  108.        on the screen, after examining the code, I don't think that's the
  109.        case. I also verified this just by playing the game, if there were
  110.        invisible trucks, the bullets would disappear. */
  111.  
  112.     if (copsnrob_trucky[0])
  113.     {
  114.         drawgfx(bitmap,Machine->gfx[2],
  115.                 0,0,
  116.                 0,0,
  117.                 0x80,256-copsnrob_trucky[0],
  118.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  119.     }
  120.  
  121.  
  122.     /* Draw the bullets.
  123.        They are flickered on/off every frame by the software, so don't
  124.        play it with frameskip 1 or 3, as they could become invisible */
  125.  
  126.     for (x = 0; x < 256; x++)
  127.     {
  128.         int y, bullet, mask1, mask2, val;
  129.  
  130.  
  131.         val = copsnrob_bulletsram[x];
  132.  
  133.         // Check for the most common case
  134.         if (!(val & 0x0f)) continue;
  135.  
  136.         mask1 = 0x01;
  137.         mask2 = 0x10;
  138.  
  139.         // Check each bullet
  140.         for (bullet = 0; bullet < 4; bullet++)
  141.         {
  142.             if (val & mask1)
  143.             {
  144.                 for (y = 0; y <= Machine->drv->visible_area.max_y; y++)
  145.                 {
  146.                     if (copsnrob_bulletsram[y] & mask2)
  147.                     {
  148.                         plot_pixel(bitmap, 256-x, y, Machine->pens[1]);
  149.                     }
  150.                 }
  151.             }
  152.  
  153.             mask1 <<= 1;
  154.             mask2 <<= 1;
  155.         }
  156.     }
  157. }
  158.